package domain;

import base.Person;
import java.util.ArrayList;
import java.util.List;

public class Student extends Person {
    private List<Course> selectedCourses = new ArrayList<>();

    public Student(String id, String name, String gender) {
        super(id, name, gender); // 调用父类构造方法
    }

    public void selectCourse(Course course) {
        selectedCourses.add(course);
        System.out.println(name + " 选修了 " + course.getCourseName() + " 课程");
    }

    public void dropCourse(Course course) {
        if (selectedCourses.remove(course)) {
            System.out.println(name + " 退选了 " + course.getCourseName() + " 课程");
        } else {
            System.out.println(name + " 未选修 " + course.getCourseName() + " 课程，无法退选");
        }
    }

    public List<Course> getSelectedCourses() {
        return selectedCourses;
    }

    // 学生特有的打印课表方法
    public void printSchedule() {
        System.out.println("\n" + name + "的课表：");
        if (selectedCourses.isEmpty()) {
            System.out.println("暂无选课");
            return;
        }
        System.out.println("编号\t课程名称\t\t上课地点\t\t时间\t\t授课教师");
        for (Course course : selectedCourses) {
            System.out.printf("%s\t%s\t%s\t%s\t%s%n",
                    course.getId(),
                    course.getCourseName(),
                    course.getLocation(),
                    course.getTime(),
                    course.getTeacher().getName());
        }
    }
}